package indi.lddsdu;

import org.junit.Test;

import java.lang.reflect.Method;

/**
 * Created by jack on 18/6/8.
 */
public class exceptionTest {

    @Test
    public void timeUseTest(){
        timeUse();
    }

    @Test
    public void nullInstanceOfInteger(){
        System.out.println(null instanceof Integer);
        System.out.println(new Integer(1) instanceof Integer);
        Integer a = null;
        System.out.println((Integer)a instanceof Integer);
    }

    public void timeUse(){
        long start = System.nanoTime();
        createAException();
        long end = System.nanoTime();
        System.out.println(String.format("time use %d ns", (end - start)));
    }

    public void conditionJudge(){
        Integer a = null;
        if (a == null){

        }
    }

    public void exceptionJudge(){
        Integer a = null;
        try {
            a.intValue();
        }catch (NullPointerException e){

        }
    }

    private void createAException(){
        Exception e = new NullPointerException();
    }

}
